/**
 * 
 */
package com.wgo.precise.client.ui.view.editor.usertypes;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import com.wgo.precise.client.ui.model.PropertyDefWrapper;
import com.wgo.precise.client.ui.model.facade.ILabelProviderItem;


class UserTypesTableLabelProvider extends LabelProvider implements ITableLabelProvider {
	public String getColumnText(Object obj, @SuppressWarnings("unused") int index) {
        String result = "";
        
		if (obj instanceof ILabelProviderItem) {
			ILabelProviderItem item = (ILabelProviderItem) obj;
			result = item.getText();
		} else if ( obj instanceof PropertyDefWrapper ) {
			PropertyDefWrapper spec = (PropertyDefWrapper) obj;
            result = spec.getLabel() + " (" + spec.getDescription() + ") [" + spec.getPropertyType().name() + "]"; 
        } else {
            result =  getText(obj);
        }
        return result;
	}

    public Image getColumnImage(Object obj, @SuppressWarnings("unused") int index) {
		return getImage(obj);
	}

    @Override
	public Image getImage(Object obj) {
        if (obj instanceof ILabelProviderItem) {
            return ((ILabelProviderItem)obj).getImage();
        } else if ( obj instanceof PropertyDefWrapper ) {
            return null;
        }
		return PlatformUI.getWorkbench().
				getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
	}
}